package com.report.controller;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.report.dto.request.PosterReq;
import com.report.dto.response.PosterRes;
import com.report.service.PosterService;
import com.zmh.framework.config.BaseCommonInterface;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author summer
 * @date 2024-07-03 15:01
 */
@RestController
@RequestMapping(value = "/poster")
@AllArgsConstructor
public class PosterController implements BaseCommonInterface<PosterReq, PosterRes> {

    private final PosterService posterService;

    @Override
    public Result<String> save(@Valid PosterReq posterReq) {
        posterService.savePoster(posterReq);
        return Result.successResult();
    }

    @Override
    public Result<String> del(Integer id) {
        posterService.removeById(id);
        return Result.successResult();
    }

    @Override
    public Result<Page<PosterRes>> lists(PosterReq posterReq) {
        return Result.successResult(posterService.lists(posterReq));
    }

    @Override
    public Result<PosterRes> findById(Integer id) {
        return Result.successResult(Convert.convert(PosterRes.class,posterService.getById(id)));
    }

    @Override
    public Result<String> batchDel(List<PosterRes> list) {
        return null;
    }
}
